package com.xbongbong.saas.script.tempenum;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.pro.enums.fund.enums.OnlinePaymentFlowStatusEnum;
import com.xbongbong.pro.enums.fund.enums.OnlinePaymentFlowTypeEnum;
import com.xbongbong.pro.enums.fund.enums.PayMethodDistributorEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.enums.OnlinePaymentFlowDistributorEnum;
import com.xbongbong.saas.enums.RedundantTemplateTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author zcp
 * @version v1.0
 * @since v1.0
 */
@Getter
public enum TempOnlinePaymentFlowDistributorEnum {
    //对账日期
    BASE_INFO(OnlinePaymentFlowDistributorEnum.BASE_INFO),
    ONLINE_APP_ID(OnlinePaymentFlowDistributorEnum.ONLINE_APP_ID),
    MCHID(OnlinePaymentFlowDistributorEnum.MCHID),
    SERIAL_NO(OnlinePaymentFlowDistributorEnum.SERIAL_NO),
    PAY_METHOD(OnlinePaymentFlowDistributorEnum.PAY_METHOD),
    AMOUNT(OnlinePaymentFlowDistributorEnum.AMOUNT),
    FEE_RATE(OnlinePaymentFlowDistributorEnum.FEE_RATE),
    AMOUNT_ACTUAL(OnlinePaymentFlowDistributorEnum.AMOUNT_ACTUAL),
    DISTRIBUTOR_ID(OnlinePaymentFlowDistributorEnum.DISTRIBUTOR_ID),
    DISTRIBUTOR_ID_LINK_TEXT(OnlinePaymentFlowDistributorEnum.DISTRIBUTOR_ID_LINK_TEXT),
    TYPE(OnlinePaymentFlowDistributorEnum.TYPE),
    STATUS(OnlinePaymentFlowDistributorEnum.STATUS),
    ORDER_ID(OnlinePaymentFlowDistributorEnum.ORDER_ID),
    ORDER_ID_LINK_TEXT(OnlinePaymentFlowDistributorEnum.ORDER_ID_LINK_TEXT),
    SHEET_ID(OnlinePaymentFlowDistributorEnum.SHEET_ID),
    SHEET_ID_LINK_TEXT(OnlinePaymentFlowDistributorEnum.SHEET_ID_LINK_TEXT),
    PAY_TIME(OnlinePaymentFlowDistributorEnum.PAY_TIME),
    PAYER_ID(OnlinePaymentFlowDistributorEnum.PAYER_ID),
    PAYER_ID_LINK_TEXT(OnlinePaymentFlowDistributorEnum.PAYER_ID_LINK_TEXT),
    PAYER(OnlinePaymentFlowDistributorEnum.PAYER),
    CREATOR_ID(OnlinePaymentFlowDistributorEnum.CREATOR_ID),
    ADD_TIME(OnlinePaymentFlowDistributorEnum.ADD_TIME),
    UPDATE_TIME(OnlinePaymentFlowDistributorEnum.UPDATE_TIME),
    PAYMENT_AMOUNT_DETAIL(OnlinePaymentFlowDistributorEnum.PAYMENT_AMOUNT_DETAIL),
    PAYMENT_ID(OnlinePaymentFlowDistributorEnum.PAYMENT_ID),
    TRANSACTION_ID(OnlinePaymentFlowDistributorEnum.TRANSACTION_ID),
    PAY_SOURCE(OnlinePaymentFlowDistributorEnum.PAY_SOURCE),
    IS_REFUND(OnlinePaymentFlowDistributorEnum.IS_REFUND),
    PAY_STATUS(OnlinePaymentFlowDistributorEnum.PAY_STATUS),
    ;

    private OnlinePaymentFlowDistributorEnum anEnum;

    TempOnlinePaymentFlowDistributorEnum(OnlinePaymentFlowDistributorEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempOnlinePaymentFlowDistributorEnum> getAllEnum() {
        List<TempOnlinePaymentFlowDistributorEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static void initSheetNo(FieldAttrEntity fieldAttrEntity){
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.PAYMENT_SHEET.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.PAYMENT_SHEET.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(SERIAL_NO.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setNoRepeat(1);
    }

    public static void initPayMethod(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(PayMethodDistributorEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setDictionaryFlag(BasicConstant.TWO);
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setShowEditable(BasicConstant.ZERO);
        fieldAttrEntity.setIsForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setNoItemLink(BasicConstant.ONE);
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setShowAttrPermission(BasicConstant.ZERO);
    }

    public static void initAmount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(1);
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setAccuracy(BasicConstant.FOUR);
    }
    public static void initAmountActual(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(1);
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setAccuracy(BasicConstant.FOUR);
    }

    public static void initDistributorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(RedundantTemplateTypeEnum.CUSTOMER.getCode());
        fieldAttrEntity.setLinkedText(DISTRIBUTOR_ID_LINK_TEXT.getAnEnum().getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setDisableListSort(1);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }

    public static void initType(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(OnlinePaymentFlowTypeEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setDictionaryFlag(BasicConstant.TWO);
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setShowEditable(BasicConstant.ZERO);
        fieldAttrEntity.setIsForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setNoItemLink(BasicConstant.ONE);
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setShowAttrPermission(BasicConstant.ZERO);
    }

    public static void initStatus(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(OnlinePaymentFlowStatusEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setDictionaryFlag(BasicConstant.TWO);
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setShowEditable(BasicConstant.ZERO);
        fieldAttrEntity.setIsForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setNoItemLink(BasicConstant.ONE);
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setShowAttrPermission(BasicConstant.ZERO);
    }

    public static void initOrderId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setLinkedText(ORDER_ID_LINK_TEXT.getAnEnum().getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        saasParticularAttributePoJo.setRelyAttr(DISTRIBUTOR_ID.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setBusinessType(XbbRefTypeEnum.ONLINE_PAYMENT_FLOW.getCode());
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setShowEditable(BasicConstant.ZERO);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }

    public static void initSheetId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.PAYMENT_SHEET.getCode());
        fieldAttrEntity.setLinkedText(SHEET_ID_LINK_TEXT.getAnEnum().getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(true);
        saasParticularAttributePoJo.setRelyAttr(ORDER_ID.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setShowEditable(BasicConstant.ZERO);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }

    /*public static void initPayerId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedText(PAYER_ID_LINK_TEXT.getAnEnum().getAttr());
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setEditable(BasicConstant.ZERO);
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setShowEditable(BasicConstant.ZERO);
    }*/

    /**
     * 初始化支付人
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initPayerId(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setIsForbidden(0);
    }


    public static void initPayerIdLinkText(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedText(PAYER_ID.getAnEnum().getAttr());
    }

}
